<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
    <meta charset="utf-8"/>
    <title>登录</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta content="width=device-width, initial-scale=1.0" name="viewport"/>
    <meta content="" name="description"/>
    <meta content="" name="author"/>
    <script src="${pageContext.request.contextPath}/assets/plugins/jquery-1.10.2.min.js" type="text/javascript"></script>
    <!-- 密码控件js引入 start -->
    <script type="text/javascript" src="${pageContext.request.contextPath}/assets/pwd/pwdBase.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/assets/pwd/pwd-PassGuardCtrl.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/assets/pwd/ca/ca2.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/assets/pwd/ca/ccitenrl2.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/assets/pwd/Base64.js" charset="GBK"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/assets/pwd/crypto-js.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/assets/pwd/microdone-crypto.js" ></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/assets/pwd/PassGuardCtrl.js?v=1" charset="GBK"></script>
    <!-- 密码控件js引入 end -->
    <!-- BEGIN PAGE LEVEL STYLES -->
    <link href="${pageContext.request.contextPath}/assets/css/pages/login.css" rel="stylesheet" type="text/css"/>
    <link href="${pageContext.request.contextPath}/assets/plugins/select2/select2.css" rel="stylesheet" type="text/css"/>
    <link href="${pageContext.request.contextPath}/assets/plugins/select2/select2-metronic.css" rel="stylesheet" type="text/css"/>
    <script>
        /**
         *调用后台时返回JSON数 据
         *
         * @param url 调用后台的URL
         * @param data 调用时需要的参数 参数格式｛key : value｝
         */
        function getJSON(url,data,successfn,completefn,bizErrorfn,errorfn){
            var result = [];
            $.ajax( {
                type : "post",
                url : url,
                cache : false,
                async : false,//这里需进行同步操作1
                data : data,
                success : function(data) {
                    if(data.success){
                        result=data;
                        if(successfn){
                            successfn(data);
                        }
                    }else{
                        if(bizErrorfn){
                            bizErrorfn(data);
                        }
                        bootbox.alert("错误提示：" + JSON.stringify(data.errorMsg));
                    }
                },error : function(XMLHttpRequest, textStatus, errorThrown) {
                    if(errorfn){
                        errorfn(XMLHttpRequest, textStatus, errorThrown);
                    }
                    if(XMLHttpRequest.readyState ===4){
                        if(XMLHttpRequest.status == 403){
                            bootbox.alert('抱歉，您无权访问该页面！');
                        }else if(XMLHttpRequest.status == 404){
                            bootbox.alert('抱歉，您访问的页面不存在！');
                        }else if(XMLHttpRequest.status == 405){
                            bootbox.alert('抱歉，您无权访问该方法！');
                        }else if(XMLHttpRequest.responseText.indexOf('</html>') > -1){
                            bootbox.alert('抱歉，您无权访问该页面！');
                        }else if(XMLHttpRequest.status == 302){
                            window.location.href = XMLHttpRequest.getResponseHeader("Location");
                        }else{
                            var json =  JSON.parse(XMLHttpRequest.responseText);
                            bootbox.alert('响应错误：'+json.errorMsg);
                        }
                    }else{
                        bootbox.alert('服务无响应,请联系管理员！');
                    }
                },complete:function(XMLHttpRequest, textStatus){
                    if(completefn){
                        completefn(XMLHttpRequest, textStatus);
                    }
                }
            });

            //根据后台错误执行特殊操作1231
            //result[0].code
            var ERROR_1 = "01990004";//会话超时，请重新登录
            if(result.errorCode==ERROR_1){
                var redirectUrl = '${redirectUrl}';
                var loginUrl = "/login";
                if(redirectUrl != ''){
                    loginUrl += '?redirectUrl='+redirectUrl+"&_time="+new Date().getTime();
                }
                window.location.href=loginUrl;
                return;

            }
            return result;
        }
    </script>
    <!-- END PAGE LEVEL SCRIPTS -->
</head>
<!-- BEGIN BODY -->
<body class="login">
<!-- BEGIN LOGO -->
<div class="logo">
    <%--<a href="${pageContext.request.contextPath}/login.jsp">--%>
        <h3 style="color: #FFFFFF">翼支付企业账户运营管理平台</h3>
    <%--</a>--%>
</div>
<object classid="CLSID:76A64158-CB41-11D1-8B02-00600806D9B6" id="locator" style="display:none;visibility:hidden"></object>
<object classid="CLSID:75718C9A-F029-11d1-A1AC-00C04FB6C223" id="foo" style="display:none;visibility:hidden"></object>

<!-- END LOGO -->
<!-- BEGIN LOGIN -->
<div class="content">
    <!-- BEGIN LOGIN FORM -->
    <form class="login-form" method="post" name="loginForm" action="${pageContext.request.contextPath}/login_auth">
        <h3 class="form-title">登录</h3>
        <input type="hidden" name="redirectUrl" value="${redirectUrl}" />
        <input type="hidden" name="loginIp" id="loginIp" />
        <div class="alert alert-danger display-hide"style="line-height: 0px;">
            <button class="close" data-close="alert" onclick="cleanup();"></button>
			<span>
				 请输入您的用户名、密码以及验证码
			</span>
        </div>
        <div class="alert alert-warning display-hide">
            <button class="close" data-close="alert" onclick="cleanup();"></button>
			<span>
				 ${loginFailMsg}
			</span>
        </div>
        <div class="form-group">
            <!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
            <label class="control-label visible-ie8 visible-ie9">用户名</label>
            <div class="input-group">
                <span class="input-group-addon">
                    <i class="fa fa-user"></i>
                </span>
                <input tabindex='1' class="form-control placeholder-no-fix" type="text" autocomplete="on" placeholder="用户名" name="username" id="username"/>
            </div>
        </div>
        <div class="form-group" id="pwd-form-group">
            <label class="control-label visible-ie8 visible-ie9">密码</label>
            <div class="input-group" style="line-height: 0px;border: 1px solid #e5e5e5;">
                <span class="input-group-addon">
                    <i class="fa fa-lock"></i>
                </span>
                <%--<input class="form-control placeholder-no-fix" type="password" autocomplete="on" placeholder="密码" name="password" id="password"/>--%>
                <input type="hidden" autocomplete="on" placeholder="密码" name="password" id="password"/>
                <div>
                    <pwd:write clazz="ossPwd" id="password" name="password" rdFromSession="true"
                               sessionKey="passwordKey" params=""  rdName="passwordRd" />
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="control-label visible-ie8 visible-ie9"style="line-height: 20px;">验证码</label>
            <div class="input-group">
                <span class="input-group-addon">
                    <i class="fa fa-check"></i>
                </span>
                <input tabindex='3' class="form-control" style="width:156px;"  type="text" placeholder="验证码" name="securityCode" id="securityCode"/>
                <img id="securityCodeImage" title="点击刷新验证码" src="${pageContext.request.contextPath}/securityCode/imageCaptcha" class="login_securityCodeImage" onclick="ajaxRefresh()"/>
            </div>
        </div>
        <div class="form-actions">
            <button type="submit" class="btn green center-block">
                登录 <i class="m-icon-swapright m-icon-white"></i>
            </button>
        </div>
    </form>
    <!-- END LOGIN FORM -->
</div>
<!-- END LOGIN -->
<!-- BEGIN COPYRIGHT -->
<%@include file="/common/copyright.html"%>
<!-- END COPYRIGHT -->
<%@include file="/common/common_foot.html"%>
<!-- BEGIN PAGE LEVEL PLUGINS -->
<script src="${pageContext.request.contextPath}/assets/plugins/jquery-validation/dist/jquery.validate.min.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/assets/plugins/jquery-validation/localization/messages_zh.js" type="text/javascript"></script>
<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN PAGE LEVEL SCRIPTS -->
<script src="${pageContext.request.contextPath}/assets/scripts/custom/login.js" type="text/javascript"></script>
<!-- END PAGE LEVEL SCRIPTS -->
<script>
    var loginFailMsg = "${loginFailMsg}";
    /**
     * 登录验证码刷新
     */
    function ajaxRefresh(){
        var verify=document.getElementById('securityCodeImage');
        verify.setAttribute('src',WWWROOT+'/securityCode/imageCaptcha?'+Math.random());
    }
    jQuery(document).ready(function() {
        if(loginFailMsg){
            $('.alert-warning', $('.login-form')).show();
        }
        App.init();
        Login.init();
//        ossAjax(WWWROOT+"/random/gen","","get");
    });

    /**
     * 当错误信息框显示时，清除火狐会出现的样式问题。
     */
    var cleanup = function(){
        $("#password-self").focus();
        setTimeout(function(){
            $("#username").focus();
            $("#username").blur();
        },20);
    }
</script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>
<script language="javascript">
    var sMacAddr = "";
    var sIPAddr = "";
    var sDNSName = "";
    var service = "";
    try {
        service = locator.ConnectServer();
        service.Security_.ImpersonationLevel = 3;
        service.InstancesOfAsync(foo, 'Win32_NetworkAdapterConfiguration');
    }catch(e){}
</script>
<script FOR="foo" EVENT="OnObjectReady(objObject,objAsyncContext)" LANGUAGE="JScript">
    if (objObject.IPEnabled != null && objObject.IPEnabled != "undefined" && objObject.IPEnabled == true) {
        if (objObject.IPEnabled && objObject.IPAddress(0) != null && objObject.IPAddress(0) != "undefined") {
            sIPAddr = objObject.IPAddress(0);
        }
        if (objObject.MACAddress != null && objObject.MACAddress != "undefined") {
            sMacAddr = objObject.MACAddress;
        }
        if (objObject.DNSHostName != null && objObject.DNSHostName != "undefined") {
            sDNSName = objObject.DNSHostName;
        }
    }
</script>

<script FOR="foo" EVENT="OnCompleted(hResult,pErrorObject, pAsyncContext)" LANGUAGE="JScript">
   $("#loginIp").val(sIPAddr);
</script>